// import {useNavigate} from "react-router-dom"
// function Car() {
//     const tiao=useNavigate()
//     return (<div>
//       <button onClick={()=>tiao("/home")}>跳转到首页</button>
//        <button onClick={()=>tiao(-1)}>返回</button>
//     </div>)
// }
// export default Car;
import { Component } from "react";
import {useParams,useLocation,useNavigate} from "react-router-dom"
function withRouter(Component) {
    return (props) => (
        <Component
            {...props}
            params={useParams()}
            location={useLocation()}
            navigate={useNavigate()}
        />
    );
}
class Car extends Component{
     render(){
         return (<div>
     <button onClick={()=>{this.props.navigate("/home")}}>跳转到首页</button>
      <button onClick={()=>{this.props.navigate(-1)}}>返回</button>
   </div>)
     }
}
export default withRouter(Car)